import api from '@/api'
import { isCode } from '@/utils'
const initState = () => {
    return {
        newAndEditCardData: {
            isNew: true,//是否是新建卡片
            isShow: false,//是否显示弹窗
            maskTransition: "",//遮罩动画名称
            cardTransition: "",//卡片动画名称
            isShowNewEdit: false,//是否显示标签input
            title: "",//来源或者标题
            desc: "",//描述
            isShowBtn: true,
            readOnly: false,
            newTagVal: "",
            tagList: [],
            typeList: [
                {
                    name: "Web",
                    id: 1,
                    isClick: false
                }, {
                    name: "Ideas",
                    id: 2,
                    isClick: false
                }, {
                    name: "Book",
                    id: 3,
                    isClick: false
                }
            ]
        },
    };
};

const state = initState();

const mutations = {
    //打开新建修改卡片弹窗
    openCardPop(state, type) {
        if (this.state.home.tabInfo.currentTab == 1) { //web
            state.newAndEditCardData.typeList[0].isClick = true;
        } else if (this.state.home.tabInfo.currentTab == 3) { //book
            state.newAndEditCardData.typeList[2].isClick = true;
        } else if (this.state.home.tabInfo.currentTab == 2) { //book
            state.newAndEditCardData.typeList[1].isClick = true;
        }
        state.newAndEditCardData.isShow = true;
        state.newAndEditCardData.cardTransition = type ? type : 'contentEnterBottom';
    },
    //关闭新建修改卡片弹窗
    closeCardPop(state, type) {
        state.newAndEditCardData.isShow = false;
        state.newAndEditCardData.cardTransition = type ? type : 'contentLeaveBottom';
        setTimeout(() => {
            this.commit('newAndEditCard/resetState');
        });
    },
    resetState(state) {
        Object.assign(state, initState());
    }
};

const actions = {

};

const getters = {};

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
};